package com.example.demo.service.Impl;

import com.example.demo.entity.Student;
import com.example.demo.mapperDAO.StudentMapper;
import com.example.demo.service.StudentService;
import com.example.demo.vo.ResponseVo;
import org.springframework.stereotype.Service;

@Service
public class StudentServiceImpl implements StudentService {

    private StudentMapper studentMapper;

    // 不用autowired是因为装配容器时有先后顺序，autowired自动装配发现组件未初始化而报错，构造器式会在装配时查找引用并初始化
    public StudentServiceImpl(StudentMapper studentMapper) {
        this.studentMapper = studentMapper;
    }

    public ResponseVo<Student> selectByPrimaryKey(Long studentId) {
        Student student = studentMapper.selectByPrimaryKey(studentId);
        return new ResponseVo<>("查询成功", 200, student);
    }
}